package com.example.mysql;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class MyData {
    public void insert(String name,String price){
        SQLiteDatabase db = helper.getWritableDatabase();
        ContentValues =new ContectValues();
        values.put("name",name);
        valees.put("price",price);
        long id = db.insert("information",null,values);
        db.close();
    }

    public int update(String name,String price){
        SQLiteDatabase db = helper.getWritableDatabase();
        ContentValues values =new ContentValues();
        values.put("price",price);
        int number =db.update("information","values","names=?",new String[] {name});
        db.close();
        return number;
    }
    public int delete (long id){
        SQLiteDatabase db=helper.getWritableDatabase();
        int number =db.delete("information","_id=?",new String[]{id+""});
        db.close();
        return number;
    }
    public boolean find(long id){
        SQLiteDatabase db=helper.getReadabltDatabase();
        Cursor cursor =db.query("information",null,"_id=?",new String []{id+""},null,null,null);
        boolean result =((Cursor) cursor).moveToNext();
        cursor.close();
        return result;
    }

}
